package ca.usask.cs.drawTree;

import ca.usask.cs.decisiontree.api.Edge;

import com.nootropic.processing.layers.Layer;

import processing.core.PApplet;
import processing.core.PFont;

public class MsgWindow extends Layer {

	int transparancy = 200;
	static final int windowColor = 0xffFFFF33;
	float windowWidth = 240;
	float windowHeight = 150;
	int lineDistance = 20;
	DrawControler controler = new DrawControler();
	PFont font;
	MsgWindow(PApplet parent) {

		super(parent); // This is necessary!
		controler = (DrawControler) parent;

	}

	public void draw() {
		background(0, 0); // clear the background every time, but be transparent
		smooth();
		strokeWeight(2);
	//	textSize(20);
		if (controler.mouseOver() && controler.checkOverNode != null) {
			createWindow(controler.mouseX, controler.mouseY,controler.checkOverNode);
			
			controler.checkOverNode = null;
		}

	}

	public void createWindow(float x, float y,TheNode n) {

		fill(windowColor, transparancy);
		rect(x, y, windowWidth, windowHeight);
		fill(0);
		textAlign(controler.LEFT);
		float fontX = x+10;
		float fontY = y+20;
		switch (n.Ndtype % 2) {
		case 0:
			DecisionNode dn = (DecisionNode) n;
			text("NodeType: "+dn.getNodeType(), fontX, fontY);
			fontY = fontY+lineDistance;
			text("NodeID: "+dn.getTreeNodeID(), fontX, fontY);
			fontY = fontY+lineDistance;
			text("The time of this layer: "+dn.getTime(), fontX, fontY);
			fontY = fontY+lineDistance;
			text("VariableName: "+dn.getVariableName(), fontX, fontY);
			fontY = fontY+lineDistance;
			text("Selected: "+dn.getSelected(), fontX, fontY);
			fontY = fontY+lineDistance;
			text("RollBackValue: "+dn.getRollBackValue(), fontX, fontY);
			break;
		case 1:
			ChanceNode cn = (ChanceNode) n;
			text("NodeType: "+cn.getNodeType(), fontX, fontY);
			fontY = fontY+lineDistance;
			text("NodeID: "+cn.getTreeNodeID(), fontX, fontY);
			fontY = fontY+lineDistance;
			text("The time of this layer: "+cn.getTime(), fontX, fontY);
			fontY = fontY+lineDistance;
			text("VariableName: "+cn.getVariableName(), fontX, fontY);
			fontY = fontY+lineDistance;
			text("Selected: "+cn.getSelected(), fontX, fontY);
			fontY = fontY+lineDistance;
			text("RollBackValue: "+cn.getRollBackValue(), fontX, fontY);	
			break;
		case -1:
			TerNode tn = (TerNode) n;
			text("NodeType: "+tn.getNodeType(), fontX, fontY);
			fontY = fontY+lineDistance;
			text("NodeID: "+tn.getTreeNodeID(), fontX, fontY);
			fontY = fontY+lineDistance;
			text("The time of this layer: "+tn.getTime(), fontX, fontY);
			fontY = fontY+lineDistance;
			text("VariableName: "+tn.getVariableName(), fontX, fontY);
			fontY = fontY+lineDistance;
			text("Selected: "+tn.getSelected(), fontX, fontY);
			fontY = fontY+lineDistance;
			text("RollBackValue: "+tn.getRollBackValue(), fontX, fontY);
			break;
		default:
			break;
		}
	
		
	}

}
